package org.example.evaluate.enums;

import java.math.BigDecimal;
import java.util.stream.Stream;

public enum Version {
    dlhh(1, "大陆行货", BigDecimal.valueOf(0.98)),
    xghh(2, "香港行货", BigDecimal.valueOf(0.95)),
    shws(3, "水货无锁", BigDecimal.valueOf(0.94)),
    shys(4, "水货有锁", BigDecimal.valueOf(0.93)),
    yd(5, "移动版", BigDecimal.valueOf(0.95)),
    dx(6, "电信版", BigDecimal.valueOf(0.93)),
    qwt(7, "全网通", BigDecimal.valueOf(0.98)),
    swt(8, "DL00-双网通", BigDecimal.valueOf(0.98)),
    bzb(9, "标准版",  BigDecimal.valueOf(0.94)),
    gpb(10, "高配版", BigDecimal.valueOf(0.95)),
    zxb(11, "尊享版", BigDecimal.valueOf(0.96));
    private final Integer code;
    private final String name;
    private final BigDecimal kf;

     Version(Integer code, String name, BigDecimal kf) {
        this.code = code;
        this.name = name;
        this.kf = kf;
    }

    public Integer getCode() {
        return code;
    }

    public BigDecimal getKf() {
        return kf;
    }

    public static Version buildVersion(Integer code) {
         return Stream.of(Version.values())
                 .filter(v -> v.getCode() == code)
                 .findFirst()
                 .orElseThrow(() -> new IllegalArgumentException(String.format("传入的版本 [%s] 不正确", code)));
    }
}
